+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
+Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types
+ to just plain new, fixing the number of columns, and column types
+ at creation time.
+
+ * gtk/gtkliststore.c (gtk_list_store_new): ditto.
+
+ * gtk/gtkcellrenderertext.c
+ (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the
+ height to a specific font.
+
+ * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness.
+
+ * tests/*c: change to work with new store models.
+
2001-06-29 Havoc Pennington <hp@redhat.com>
* Throughout: fixes to compile with G_DISABLE_COMPAT
GtkTreeIter iter;
gint i;
- model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+ model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
GSList *ids;
GSList *tmp_list;
- store = gtk_list_store_new_with_types (1, STOCK_ITEM_INFO_TYPE);
+ store = gtk_list_store_new (1, STOCK_ITEM_INFO_TYPE);
ids = gtk_stock_list_ids ();
ids = g_slist_sort (ids, (GCompareFunc) strcmp);
PROP_YALIGN,
PROP_XPAD,
PROP_YPAD,
+ PROP_WIDTH,
+ PROP_HEIGHT,
};
cell->can_activate = FALSE;
cell->visible = TRUE;
+ cell->width = -1;
+ cell->height = -1;
cell->xalign = 0.5;
cell->yalign = 0.5;
cell->xpad = 0;
2,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_WIDTH,
+ g_param_spec_int ("width",
+ _("width"),
+ _("The fixed width."),
+ -1,
+ 100,
+ -1,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_HEIGHT,
+ g_param_spec_int ("height",
+ _("height"),
+ _("The fixed height."),
+ -1,
+ 100,
+ -1,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
}
static void
case PROP_YPAD:
g_value_set_uint (value, cell->ypad);
break;
+ case PROP_WIDTH:
+ g_value_set_int (value, cell->width);
+ break;
+ case PROP_HEIGHT:
+ g_value_set_int (value, cell->height);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
cell->ypad = g_value_get_uint (value);
g_object_notify (object, "ypad");
break;
+ case PROP_WIDTH:
+ cell->width = g_value_get_int (value);
+ g_object_notify (object, "width");
+ break;
+ case PROP_HEIGHT:
+ cell->height = g_value_get_int (value);
+ g_object_notify (object, "height");
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
gint *width,
gint *height)
{
+ gint *real_width = NULL;
+ gint *real_height = NULL;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
- GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
+ if (width)
+ {
+ if (cell->width == -1)
+ real_width = width;
+ else
+ *width = cell->width;
+ }
+ if (height)
+ {
+ if (cell->height == -1)
+ real_height = height;
+ else
+ *height = cell->height;
+ }
+
+ if (real_width || real_height)
+ GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, real_width, real_height);
}
/**
flags);
}
+/**
+ * gtk_cell_renderer_set_fixed_size:
+ * @cell: A #GtkCellRenderer
+ * @width: the width of the cell renderer, or -1
+ * @height: the height of the cell renderer, or -1
+ *
+ * Sets the renderer size to be explicit, independent of the properties set.
+ **/
+void
+gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
+ gint width,
+ gint height)
+{
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+ g_return_if_fail (width >= -1 && height >= -1);
+
+ if (width != cell->width)
+ {
+ cell->width = width;
+ g_object_notify (G_OBJECT (cell), "width");
+ }
+
+ if (height != cell->height)
+ {
+ cell->height = height;
+ g_object_notify (G_OBJECT (cell), "height");
+ }
+}
+
+/**
+ * gtk_cell_renderer_get_fixed_size:
+ * @cell: A #GtkCellRenderer
+ * @width: location to fill in with the fixed width of the widget, or %NULL
+ * @height: location to fill in with the fixed height of the widget, or %NULL
+ *
+ * Fills in @width and @height with the appropriate size of @cell.
+ **/
+void
+gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
+ gint *width,
+ gint *height)
+{
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+ if (width)
+ (* width) = cell->width;
+ if (height)
+ (* height) = cell->height;
+}
{
GtkObject parent;
- gboolean can_activate;
- gboolean visible;
-
gfloat xalign;
gfloat yalign;
+ gint width;
+ gint height;
+
guint16 xpad;
guint16 ypad;
+
+ guint can_activate : 1;
+ guint visible : 1;
};
struct _GtkCellRendererClass
GtkCellRendererState flags);
};
-GtkType gtk_cell_renderer_get_type (void);
-void gtk_cell_renderer_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *cell_area,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height);
-void gtk_cell_renderer_render (GtkCellRenderer *cell,
- GdkWindow *window,
- GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- GtkCellRendererState flags);
-gboolean gtk_cell_renderer_event (GtkCellRenderer *cell,
- GdkEvent *event,
- GtkWidget *widget,
- gchar *path,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GtkCellRendererState flags);
+GtkType gtk_cell_renderer_get_type (void);
+void gtk_cell_renderer_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height);
+void gtk_cell_renderer_render (GtkCellRenderer *cell,
+ GdkWindow *window,
+ GtkWidget *widget,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GdkRectangle *expose_area,
+ GtkCellRendererState flags);
+gboolean gtk_cell_renderer_event (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags);
+void gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
+ gint width,
+ gint height);
+void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
+ gint *width,
+ gint *height);
+
#ifdef __cplusplus
}
GTK_CELL_RENDERER (celltext)->yalign = 0.5;
GTK_CELL_RENDERER (celltext)->xpad = 2;
GTK_CELL_RENDERER (celltext)->ypad = 2;
+
+ celltext->fixed_height_rows = -1;
}
static void
if (font_desc)
pango_font_description_free (font_desc);
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
}
break;
case PROP_FONT_DESC:
set_font_description (celltext, g_value_get_boxed (value));
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_FAMILY:
g_object_notify (G_OBJECT (celltext), "family_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_STYLE:
g_object_notify (G_OBJECT (celltext), "style_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_VARIANT:
g_object_notify (G_OBJECT (celltext), "variant_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_WEIGHT:
g_object_notify (G_OBJECT (celltext), "weight_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_STRETCH:
g_object_notify (G_OBJECT (celltext), "stretch_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_SIZE:
g_object_notify (G_OBJECT (celltext), "size_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_SCALE:
celltext->font_scale = g_value_get_double (value);
celltext->scale_set = TRUE;
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_SIZE_POINTS:
g_object_notify (G_OBJECT (celltext), "size_set");
g_object_notify (G_OBJECT (celltext), "font_desc");
g_object_notify (G_OBJECT (celltext), "font");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_EDITABLE:
celltext->rise = g_value_get_int (value);
celltext->rise_set = TRUE;
g_object_notify (G_OBJECT (celltext), "rise_set");
+ if (celltext->fixed_height_rows != -1)
+ celltext->calc_fixed_height = TRUE;
break;
case PROP_BACKGROUND_SET:
gint *width,
gint *height)
{
- GtkCellRendererText *celltext = (GtkCellRendererText *)cell;
+ GtkCellRendererText *celltext = (GtkCellRendererText *) cell;
PangoRectangle rect;
PangoLayout *layout;
- if (celltext->fixed_size)
+ if (celltext->calc_fixed_height)
{
- if (width)
- *width = celltext->width;
- if (height)
- *height = celltext->height;
+ PangoContext *context;
+ PangoFontMetrics metrics;
+ PangoFontDescription font_desc;
+
+ font_desc = (* widget->style->font_desc);
+
+ if (celltext->family_set &&
+ celltext->font.family_name)
+ font_desc.family_name = celltext->font.family_name;
+ if (celltext->style_set)
+ font_desc.style = celltext->font.style;
- return;
+ if (celltext->variant_set)
+ font_desc.variant = celltext->font.variant;
+
+ if (celltext->weight_set)
+ font_desc.weight = celltext->font.weight;
+
+ if (celltext->stretch_set)
+ font_desc.stretch = celltext->font.stretch;
+
+ if (celltext->size_set &&
+ celltext->font.size >= 0)
+ font_desc.size = celltext->font.size;
+
+ context = gtk_widget_get_pango_context (widget);
+ pango_context_get_metrics (context,
+ &font_desc,
+ pango_context_get_language (context),
+ &metrics);
+ gtk_cell_renderer_set_fixed_size (cell,
+ cell->width, 2*cell->ypad +
+ celltext->fixed_height_rows*(metrics.ascent + metrics.descent)/PANGO_SCALE);
+ if (height)
+ {
+ *height = cell->height;
+ height = NULL;
+ }
+ celltext->calc_fixed_height = FALSE;
+ if (width == NULL)
+ return;
}
-
layout = get_layout (celltext, widget, FALSE, 0);
pango_layout_get_pixel_extents (layout, NULL, &rect);
}
/**
- * gtk_cell_renderer_text_set_fixed_size:
+ * gtk_cell_renderer_text_set_fixed_height_from_font:
* @renderer: A #GtkCellRendererText
- * @fixed_size: TRUE if the renderer should be a fixed height.
- * @width: The width of the cell
- * @height: The height it of the cell, or -1
+ * @number_of_rows: Number of rows of text each cell renderer is allocated, or -1
*
- * Sets the height of a renderer to explicitly be a certain size. This
- * function is unflexible, and should really only be used if calculating the
- * size of a cell is too slow.
+ * Sets the height of a renderer to explicitly be determined by the "font" and
+ * "y_pad" property set on it. Further changes in these properties do not
+ * affect the height, so they must be accompanied by a subsequent call to this
+ * function. Using this function is unflexible, and should really only be used
+ * if calculating the size of a cell is too slow. If @no_rows is -1, then the
+ * fixed height is unset, and the height is determined by the properties again.
**/
void
-gtk_cell_renderer_text_set_fixed_size (GtkCellRendererText *renderer,
- gboolean fixed_size,
- gint width,
- gint height)
+gtk_cell_renderer_text_set_fixed_height_from_font (GtkCellRendererText *renderer,
+ gint number_of_rows)
{
g_return_if_fail (GTK_IS_CELL_RENDERER_TEXT (renderer));
+ g_return_if_fail (number_of_rows == -1 || number_of_rows > 0);
- if (renderer->fixed_size == (fixed_size)?TRUE:FALSE)
- return;
-
- renderer->fixed_size = (fixed_size)?TRUE:FALSE;
- renderer->height = height;
- renderer->width = width;
-
+ if (number_of_rows == -1)
+ {
+ gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (renderer),
+ GTK_CELL_RENDERER (renderer)->width,
+ -1);
+ }
+ else
+ {
+ renderer->fixed_height_rows = number_of_rows;
+ renderer->calc_fixed_height = TRUE;
+ }
}
PangoUnderline underline_style;
gint rise;
- gint width;
- gint height;
+ gint fixed_height_rows;
- guint fixed_size : 1;
guint strikethrough : 1;
/* editable feature doesn't work */
guint strikethrough_set : 1;
guint editable_set : 1;
+ guint calc_fixed_height : 1;
};
struct _GtkCellRendererTextClass
GtkCellRendererClass parent_class;
};
-GtkType gtk_cell_renderer_text_get_type (void);
-GtkCellRenderer *gtk_cell_renderer_text_new (void);
+GtkType gtk_cell_renderer_text_get_type (void);
+GtkCellRenderer *gtk_cell_renderer_text_new (void);
-void gtk_cell_renderer_text_set_fixed_size (GtkCellRendererText *renderer,
- gboolean fixed_size,
- gint width,
- gint height);
+void gtk_cell_renderer_text_set_fixed_height_from_font (GtkCellRendererText *renderer,
+ gint number_of_rows);
#ifdef __cplusplus
GtkTreeIter *child);
+static void gtk_list_store_set_n_columns (GtkListStore *list_store,
+ gint n_columns);
+static void gtk_list_store_set_column_type (GtkListStore *list_store,
+ gint column,
+ GType type);
+
+
/* Drag and Drop */
static gboolean gtk_list_store_drag_data_delete (GtkTreeDragSource *drag_source,
GtkTreePath *path);
/**
* gtk_list_store_new:
- *
- * Creates a new #GtkListStore. A #GtkListStore implements the
- * #GtkTreeModel interface, and stores a linked list of
- * rows; each row can have any number of columns. Columns are of uniform type,
- * i.e. all cells in a column have the same type such as #G_TYPE_STRING or
- * #GDK_TYPE_PIXBUF. Use #GtkListStore to store data to be displayed in a
- * #GtkTreeView.
- *
- * Return value: a new #GtkListStore
- **/
-GtkListStore *
-gtk_list_store_new (void)
-{
- return GTK_LIST_STORE (g_object_new (gtk_list_store_get_type (), NULL));
-}
-
-/**
- * gtk_list_store_new_with_types:
* @n_columns: number of columns in the list store
* @Varargs: all #GType types for the columns, from first to last
*
- * Creates a new list store as with gtk_list_store_new(), simultaneously setting
- * up the columns and column types as with gtk_list_store_set_n_columns() and
- * gtk_list_store_set_column_type(). As an example,
- * gtk_tree_store_new_with_types (3, G_TYPE_INT, G_TYPE_STRING,
- * GTK_TYPE_PIXBUF); will create a new GtkListStore with three columns, of type
- * int, string and GtkPixbuf respectively.
+ * Creates a new list store as with @n_columns columns each of the types passed
+ * in. As an example, gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING,
+ * GDK_TYPE_PIXBUF); will create a new GtkListStore with three columns, of type
+ * int, string and GDkPixbuf respectively.
*
* Return value: a new #GtkListStore
**/
GtkListStore *
-gtk_list_store_new_with_types (gint n_columns,
+gtk_list_store_new (gint n_columns,
...)
{
GtkListStore *retval;
g_return_val_if_fail (n_columns > 0, NULL);
- retval = gtk_list_store_new ();
+ retval = GTK_LIST_STORE (g_object_new (gtk_list_store_get_type (), NULL));
gtk_list_store_set_n_columns (retval, n_columns);
va_start (args, n_columns);
return retval;
}
-/**
- * gtk_list_store_set_n_columns:
- * @store: a #GtkListStore
- * @n_columns: number of columns
- *
- * Sets the number of columns in the #GtkListStore.
- *
- **/
-void
+static void
gtk_list_store_set_n_columns (GtkListStore *list_store,
gint n_columns)
{
list_store->n_columns = n_columns;
}
-/**
- * gtk_list_store_set_column_type:
- * @store: a #GtkListStore
- * @column: column number
- * @type: type of the data stored in @column
- *
- * Supported types include: %G_TYPE_UINT, %G_TYPE_INT, %G_TYPE_UCHAR,
- * %G_TYPE_CHAR, %G_TYPE_BOOLEAN, %G_TYPE_POINTER, %G_TYPE_FLOAT,
- * %G_TYPE_DOUBLE, %G_TYPE_STRING, %G_TYPE_OBJECT, and %G_TYPE_BOXED, along with
- * subclasses of those types such as %GDK_TYPE_PIXBUF.
- *
- **/
-void
+static void
gtk_list_store_set_column_type (GtkListStore *list_store,
gint column,
GType type)
GtkType gtk_list_store_get_type (void);
-GtkListStore *gtk_list_store_new (void);
-GtkListStore *gtk_list_store_new_with_types (gint n_columns,
+GtkListStore *gtk_list_store_new (gint n_columns,
...);
-void gtk_list_store_set_n_columns (GtkListStore *store,
- gint n_columns);
-void gtk_list_store_set_column_type (GtkListStore *store,
- gint column,
- GType type);
void gtk_list_store_set_value (GtkListStore *store,
GtkTreeIter *iter,
gint column,
GtkTreeIter *child);
+static void gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
+ gint n_columns);
+static void gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
+ gint column,
+ GType type);
+
+
/* DND interfaces */
static gboolean gtk_tree_store_drag_data_delete (GtkTreeDragSource *drag_source,
GtkTreePath *path);
}
GtkTreeStore *
-gtk_tree_store_new (void)
-{
- return GTK_TREE_STORE (g_object_new (GTK_TYPE_TREE_STORE, NULL));
-}
-
-GtkTreeStore *
-gtk_tree_store_new_with_types (gint n_columns,
+gtk_tree_store_new (gint n_columns,
...)
{
GtkTreeStore *retval;
g_return_val_if_fail (n_columns > 0, NULL);
- retval = gtk_tree_store_new ();
+ retval = GTK_TREE_STORE (g_object_new (GTK_TYPE_TREE_STORE, NULL));
gtk_tree_store_set_n_columns (retval, n_columns);
va_start (args, n_columns);
GtkType gtk_tree_store_get_type (void);
-GtkTreeStore *gtk_tree_store_new (void);
-
-GtkTreeStore *gtk_tree_store_new_with_types (gint n_columns,
+GtkTreeStore *gtk_tree_store_new (gint n_columns,
...);
-void gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
- gint n_columns);
-void gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
- gint column,
- GType type);
void gtk_tree_store_set_value (GtkTreeStore *tree_store,
GtkTreeIter *iter,
gint column,
background_area.width,
background_area.height);
- if (gtk_tree_view_is_expander_column(tree_view, column) &&
+ if (gtk_tree_view_is_expander_column (tree_view, column) &&
TREE_VIEW_DRAW_EXPANDERS(tree_view))
{
cell_area.x += depth*tree_view->priv->tab_offset;
{
GList *list;
- if (tree_view->priv->expander_column == column)
- return TRUE;
-
- if (column != NULL)
- return FALSE;
-
- for (list = tree_view->priv->columns; list; list = list->next)
- if (((GtkTreeViewColumn *)list->data)->visible)
- break;
- if (list && list->data == column)
- return TRUE;
+ if (tree_view->priv->expander_column != NULL)
+ {
+ if (tree_view->priv->expander_column == column)
+ return TRUE;
+ return FALSE;
+ }
+ else
+ {
+ for (list = tree_view->priv->columns; list; list = list->next)
+ if (((GtkTreeViewColumn *)list->data)->visible)
+ break;
+ if (list && list->data == column)
+ return TRUE;
+ }
return FALSE;
}
* @destroy: Destroy notifier for @data, or NULL
*
* This function should almost never be used. It is meant for private use by
- * ATK for determining the number of visible rows that are removed when the user
- * collapses a row, or a row is deleted.
+ * ATK for determining the number of visible children that are removed when the
+ * user collapses a row, or a row is deleted.
**/
void
gtk_tree_view_set_destroy_count_func (GtkTreeView *tree_view,
GtkTreeCellDataFunc func;
gpointer func_data;
GtkDestroyNotify destroy;
+ gint requested_width;
guint16 padding;
guint expand : 1;
guint fill : 1;
}
}
+
+/**
+ * gtk_tree_view_column_set_spacing:
+ * @tree_column: A #GtkTreeViewColumn.
+ * @spacing: distance between cell renderers in pixels.
+ *
+ * Sets the spacing field of @tree_column, which is the number of pixels to
+ * place between cell renderers packed into it.
+ **/
+void
+gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
+ gint spacing)
+{
+ g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
+ g_return_if_fail (spacing >= 0);
+
+ if (tree_column->spacing == spacing)
+ return;
+
+ tree_column->spacing = spacing;
+ if (tree_column->tree_view)
+ {
+ tree_column->dirty = TRUE;
+ gtk_widget_queue_resize (tree_column->tree_view);
+ }
+}
+
+/**
+ * gtk_tree_view_column_get_spacing:
+ * @tree_column: A #GtkTreeViewColumn.
+ *
+ * Returns the spacing of @tree_column.
+ **/
+gint
+gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column)
+{
+ g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), 0);
+
+ return tree_column->spacing;
+}
+
/* Options for manipulating the columns */
/**
gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
gboolean visible)
{
- g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
visible = !! visible;
gfloat xalign;
guint property_changed_signal;
+ gint spacing;
gint width;
gint requested_width;
gint min_width;
GtkDestroyNotify destroy);
void gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer);
+void gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
+ gint spacing);
+gint gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
gboolean visible);
gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column);
gtk_init (&argc, &argv);
/* First initialize all the models for signal purposes */
- left_tree_model = (GtkTreeModel *) gtk_list_store_new_with_types (2, G_TYPE_STRING, GTK_TYPE_POINTER);
- sample_model = (GtkTreeModel *) gtk_list_store_new_with_types (1, G_TYPE_STRING);
+ left_tree_model = (GtkTreeModel *) gtk_list_store_new (2, G_TYPE_STRING, GTK_TYPE_POINTER);
+ sample_model = (GtkTreeModel *) gtk_list_store_new (1, G_TYPE_STRING);
sample_tree_view_top = gtk_tree_view_new_with_model (sample_model);
sample_tree_view_bottom = gtk_tree_view_new_with_model (sample_model);
top_right_tree_model = (GtkTreeModel *) view_column_model_new (GTK_TREE_VIEW (sample_tree_view_top));
TreeStruct *month = toplevel;
GtkTreeIter iter;
- model = gtk_tree_store_new_with_types (NUM_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN);
+ model = gtk_tree_store_new (NUM_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN);
while (month->label)
{
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
- model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
// gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), 0, GTK_TREE_SORT_ASCENDING);
g_print ("start model\n");
tree_view = gtk_tree_view_new_with_model (model);
NULL);
setup_column (col);
+ gtk_tree_view_set_expander_column (tree_view, col);
+
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
#endif
- gtk_tree_view_set_expander_column (tree_view, 1);
-
/* FALL THRU */
case COLUMNS_ONE:
t = get_model_types ();
- store = gtk_list_store_new_with_types (N_COLUMNS,
- t[0], t[1], t[2],
- t[3], t[4], t[5],
- t[6], t[7], t[8]);
+ store = gtk_list_store_new (N_COLUMNS,
+ t[0], t[1], t[2],
+ t[3], t[4], t[5],
+ t[6], t[7], t[8]);
i = 0;
while (i < 200)
t = get_model_types ();
- store = gtk_tree_store_new_with_types (N_COLUMNS,
- t[0], t[1], t[2],
- t[3], t[4], t[5],
- t[6], t[7], t[8]);
+ store = gtk_tree_store_new (N_COLUMNS,
+ t[0], t[1], t[2],
+ t[3], t[4], t[5],
+ t[6], t[7], t[8]);
i = 0;
while (i < G_TYPE_RESERVED_LAST_FUNDAMENTAL)
models[MODEL_SORTED_TREE] = gtk_tree_model_sort_new_with_model (model);
g_object_unref (G_OBJECT (model));
- models[MODEL_EMPTY_LIST] = GTK_TREE_MODEL (gtk_list_store_new ());
- models[MODEL_EMPTY_TREE] = GTK_TREE_MODEL (gtk_tree_store_new ());
+ models[MODEL_EMPTY_LIST] = GTK_TREE_MODEL (gtk_list_store_new (0));
+ models[MODEL_EMPTY_TREE] = GTK_TREE_MODEL (gtk_tree_store_new (0));
models[MODEL_NULL] = NULL;
gint i;
GtkTreeIter iter;
- store = gtk_list_store_new_with_types (1, G_TYPE_INT);
+ store = gtk_list_store_new (1, G_TYPE_INT);
model = GTK_TREE_MODEL (store);
GtkTreeStore *store;
GtkTreeIter root;
- store = gtk_tree_store_new_with_types (1, G_TYPE_INT);
+ store = gtk_tree_store_new (1, G_TYPE_INT);
gtk_tree_model_get_iter_root (GTK_TREE_MODEL (store), &root);
treestore_torture_recurse (store, &root, 0);
{
gtk_init (&argc, &argv);
- base_model = gtk_tree_store_new_with_types (2, G_TYPE_STRING, G_TYPE_STRING);
+ base_model = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
/* FIXME: reverse this */
make_window (0);